
    AlphaEst = function(x.delta, z, y, f.z.x.est, delta.d.est, weights){
        
        pa = ncol(x.delta)
        
        bipw.objective = function(pars){
            alpha = pars[1:pa]
            obj   = t(x.delta * weights) %*% ( y * (2*z - 1) / 
                                                   (f.z.x.est * delta.d.est) - 
                              tanh(x.delta %*% alpha))
            return(sum(obj^2))
        }
        
        startpars = rep(0,pa)
        opt = Optimize(bipw.objective, startpars)
        
        return(opt)
        
    }